<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/framework.tld" prefix="mayi"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/jquery-3.1.1.min.js"></script>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<title>歌曲管理</title>
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/frame/layui/css/layui.css">
<!--<link rel="stylesheet" href="http://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">-->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/frame/static/css/style.css">
<link rel="icon"
	href="<%=request.getContextPath()%>/frame/static/image/code.png">
</head>
<body class="body">

	<div class="my-btn-box">
		<span class="fl"> <a
			class="layui-btn layui-btn-danger radius btn-delect"
			id="btn-delete-all" onclick="del()">批量删除</a><a
			class="layui-btn layui-btn-danger radius btn-delect"
			id="btn-delete-all" onclick="check()">审核提交</a> <a
			class="layui-btn btn-add btn-default" id="btn-add"
			href="<%=request.getContextPath()%>/manager/toMsongAdd">添加歌曲</a> <a
			class="layui-btn btn-add btn-default" id="btn-refresh"
			href="<%=request.getContextPath()%>/manager/selectVatSongs">审核歌曲</a><a
			class="layui-btn layui-btn-primary"
			href="<%=request.getContextPath()%>/manager/toMindex">管理员</a>
		</span>
		<form class="layui-form"
			action="<%=request.getContextPath()%>/manager/selectSongs"
			method="post">
			<span class="fr">
				<div class="layui-form-item">
					<div class="layui-input-inline">
						<select name="radio" id="radio">
							<option value="0">搜索选项</option>
							<option value="1">歌手名</option>
							<option value="2">歌曲名称</option>
						</select>
					</div>
					<div class="layui-input-inline">
						<input type="text" name="search" id="search" autocomplete="off"
							placeholder="请输入搜索条件" class="layui-input">

					</div>
					<div class="layui-input-inline">
						<button class="layui-btn mgl-20" onclick="search()" type="submit">查询</button>

					</div>
					<div class="layui-form-mid layui-word-aux"></div>
				</div>
		</form>
	</div>


	<table class="layui-table">
		<colgroup>
			<col width="150">
			<col width="150">
			<col width="200">
			<col>
		</colgroup>
		<thead>
			<tr>
				<th>删除/审核</th>
				<th>歌名</th>
				<th>歌手</th>
				<th>时长</th>
				<th>歌曲种类</th>
				<th>点击量</th>
				<th>路径</th>
				<th>修改</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<c:forEach items="${songList }" var="songList">
					<tr>
						<td><input type="checkbox" name="songId"
							value="${songList.songId}"></td>
						<td><a href="<%=request.getContextPath()%>/manager/songDetail?songId=${songList.songId}">${songList.songName }</a></td>
						<td>${songList.singer }</td>
						<td>${songList.time }</td>
						<td><c:if test="${songList.typeId== 1}">说唱</c:if> <c:if
								test="${songList.typeId== 2}">摇滚</c:if> <c:if
								test="${songList.typeId== 3}">流行</c:if> <c:if
								test="${songList.typeId== 4}">民谣</c:if></td>
						<td>${songList.songCounts }</td>
						<td>${songList.src }</td>
						<td align="center"><a onclick="update(${songList.songId})">修改</a></td>
					</tr>
				</c:forEach>
			</tr>
		</tbody>
	</table>

	<div>
		<p>
			<font size="5"> <!-- 总页数，当前页，总记录数 --> <mayi:page
					url="${pageContext.request.contextPath}/manager/toMSong?curPage"
					totalPage="${page.totalPage }" curPage="${page.curPage }"
					rows="${page.rows }"></mayi:page>
			</font>
		</p>
	</div>

	<!-- 表格操作按钮集 -->
	<script type== "type/html" id="barOption">
    <a class="layui-btn layui-btn-mini" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-mini layui-btn-normal" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-mini layui-btn-danger" lay-event="del">删除</a>
</script>
	<script src="<%=request.getContextPath()%>/frame/layui/layui.js"
		charset="utf-8"></script>
	<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
                ,layer = layui.layer
                ,layedit = layui.layedit
                ,laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 5){
                    return '标题至少得5个字符啊';
                }
            }
            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });

        //监听指定开关
        form.on('switch(switchTest)', function(data){
            layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });

        //监听提交
        form.on('submit(demo1)', function(data){
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            });
            return false;
        });


    });
</script>
</body>

<script type="text/javascript">
function update(songId){
	window.location.href="<%=request.getContextPath()%>/manager/toMSongUpdate?songId="+songId;
}

function del(){
	var obj = document.getElementsByName("songId");
	ids = [];
	for (k in obj) {
		if (obj[k].checked)
			ids.push(obj[k].value);
	}
	if (ids.length == 0) {
		//alert("请选择要删除的记录");
	} else {
		var flag = window.confirm("确认要删除吗？");
		if (flag) {
			window.location.href = "<%=request.getContextPath()%>/manager/deleteSongs" + "?ids=" + ids;
		}
	}
}

function check(){
	var obj = document.getElementsByName("songId");
	ids = [];
	for (k in obj) {
		if (obj[k].checked)
			ids.push(obj[k].value);
	}
	if (ids.length == 0) {
		//alert("请选择要删除的记录");
	} else {
		var flag = window.confirm("确认通过审核？");
		if (flag) {
			window.location.href = "<%=request.getContextPath()%>/manager/submitSongs" + "?ids=" + ids;
		}
	}
}
</script>

</html>